<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .inp_box{
        display: flex;
        justify-content: center;

    }
    ul{
        padding: 0;
        margin: 0;
    }
    ul li{
        list-style: none;
        padding: 5px 10px;
    }
    .list_box{
        width: 214px;
        height: 200px;
        border: 1px solid #ccc;
        margin: 0 auto;
    }
    .hide{
        display: none;
    }
    .show{
        display: block;
    }
    
    </style>
</head>

<body>
    <div class="box">
        <div class="inp_box">
            <input type="text" placeholder="请输入内容..." id="text">
            <input type="button" value="搜索" id="search">
        </div>
        <div class="list_box hide">
            <ul id="ul">

            </ul>
        </div>

    </div>

    <script src="../jquery-1.12.4.js"></script>
    <script>
        var arr = ['苹果', '坚果', '如果', '橘子', "例子"]
        var textObj = $("#text").val()
        console.log(textObj)
        for (var i = 0; i < arr.length; i++) {
            $('#ul').append('<li>' + arr[i] + '</li>')
        }
        $('#search').on('click', function () {
            $('.list_box').toggle()
        })

        $('#text').on('focus',function(){

        })
    </script>
</body>

</html>